#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
static int is_running = 1;
static void create_resource(void){
    printf("create_resource\n");
}

static void destroy_resource(void){
    printf("destroy_resource\n");
}

void signal_handler(int signum){
    if (signum == SIGINT)
    {
        printf("SIGINT received\n");
        is_running = 0;
    }
    else if (signum == SIGTERM){

        printf("SIGTERM received\n");
        destroy_resource();
        exit(0);
    }
    
}


int main(int argc, char const *argv[])
{
    
    create_resource();
    signal(SIGINT, signal_handler); // ignore SIGINT (Ctrl+C)
    signal(SIGTERM, signal_handler); // kill

    while (is_running)    
    {
        printf("running...\n");
        sleep(1);
    }

    destroy_resource();
    
    return 0;
}
